<?php
/**
 *
 * Author: LiuJianPeng
 * Date: 2023/8/7
 * Time: 17:52
 */

namespace App\OpenApi\AdminApi\Admin;

use App\Service\Core\Admin\Log\AdminLogListService;
use App\Service\Core\Admin\LoginLog\AdminLoginLogListService;
use App\Service\OpenApi\AdminApi\OpenBaseApi;

class AdminLogApi extends OpenBaseApi
{

    /**
     * 获取操作日志列表
     * @return array
     */
    public function index(): array
    {
        $list_res = (new AdminLogListService())
            ->setStartTime($this->input('start_time'))
            ->setEndTime($this->input('end_time'))
            ->setKeyword($this->input('keyword'))
            ->setPage($this->input('page', 1), $this->input('pageSize', $this->page_size))
            ->getList();
        return alert_info(0, '获取成功', $list_res);
    }

    /**
     * 获取登录日志列表
     * @return array
     */
    public function loginIndex(): array
    {
        $list_res = (new AdminLoginLogListService())
            ->setFields(['*', 'source_name'])
            ->setStartTime($this->input('start_time'))
            ->setEndTime($this->input('end_time'))
            ->setKeyword($this->input('keyword'))
            ->setPage($this->input('page', 1), $this->input('pageSize', $this->page_size))
            ->getList();

        return alert_info(0, '获取成功', $list_res);
    }
}
